<!--
 * @Date: 2021-05-05 17:30:28
 * @LastEditTime: 2022-01-13 12:20:29
-->
<template>
  <el-dialog :visible.sync="visible" center width="1200px" class="warehouse_order_info_dialog" @close="handleCancel">
    <div v-loading="loadingShow" style="text-align: center;">
      <warehouse-order-info :warehouse-order-info="info" :base-fields="baseFields" :number-desc="numberDesc" :show-parts="showParts" />
      <span slot="footer">
        <el-button type="primary" @click="handleCancel">返回</el-button>
      </span>
    </div>
  </el-dialog>
</template>

<script>
import warehouseOrderInfo from './warehouseOrderInfo'
export default {
  name: 'WarehouseOrderInfoDialog',
  components: {
    warehouseOrderInfo
  },
  props: {
    baseFields: {
      // 基本信息字段
      type: Array,
      default() {
        return []
      }
    },
    numberDesc: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      visible: false,
      info: {},
      showParts: false,
      loadingShow: false
    }
  },
  computed: {},
  created() { },
  methods: {
    // 显示
    show({ info, showParts, id, type }) {
      const vm = this
      let url
      vm.loadingShow = true
      vm.visible = true
      if (id) {
        if (type === 'warehouse') {
          url = 'warehouse-order'
        } else if (type === 'outbound') {
          url = 'outbound-order'
        }
        vm.$http
          .get(`/${url}/${id}`)
          .then((res) => {
            vm.info = res.data
            vm.loadingShow = false
          }).catch(() => {
            vm.loadingShow = false
          })
      } else {
        vm.showParts = showParts
        vm.info = info
        vm.loadingShow = false
      }
    },
    // 关闭
    handleCancel() {
      const vm = this
      vm.info = {}
      vm.visible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.warehouse_order_info_dialog ::v-deep .el-dialog__header {
  padding: 0;
}
.warehouse_order_info_dialog ::v-deep .el-dialog__body {
  padding: 16px 16px 14px;
}
</style>
